/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.tkgarment.system.dao;

import com.tkgarment.system.domain.Nationality;
import com.tkgarment.system.factory.DAOFactory;
import com.tkgarment.system.inf.IDAO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *
 * @author zraj
 */
public class NationalityDAO extends AbstractDAO implements IDAO<Nationality, Integer> {

    @Override
    public List<Nationality> getAll() throws Exception {
        String sql = "select * from nationality order by "+ Nationality.field_name +"  ASC";
        if (this.getCon() == null) {
            this.setCon(DAOFactory.creatConnection());
        }
        List<Map<String , Object>> result = this.getCon().queryList(sql);
        List<Nationality> nts = new ArrayList<>();
        for (Map<String, Object> map : result) {
            Nationality n = new Nationality();
            n.setNationalityID(Integer.parseInt(map.get(Nationality.field_nationality_id).toString()));
            n.setName(map.get(Nationality.field_name).toString());
            nts.add(n);
        }
        
        return nts;
    }

    @Override
    public int updateSingle(Nationality t, Integer id) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int deleteSingle(Nationality t) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int insertSingle(Nationality t) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Nationality getById(Integer id) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}
